import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

function getRandom(min, max) {
	return Math.floor(Math.random() * (max - min + 1)) + min; 
}

export default new Vuex.Store({
  state: {
    currentColor:"#000000",
    // colors:["red","blue","pink","yellow"]
  },
  // getters:{
  //   currentColor:function(state){
  //     let index = getRandom(0,3);
  //     return state.colors[index]
  //   }
  // },
  mutations: {
    CHANGE_COLOR(state){
      // let index = getRandom(0,3);
      // state.currentColor = state.colors[index]
      let chars = ["0","1","2","3","4","5","a","b"];
      let temp = "#";
      for(let index=0;index<6;index++){
        let index = getRandom(0,chars.length-1);
        temp+=chars[index]
      }
      state.currentColor = temp;
    }
  },
  actions: {
  },
  modules: {
  }
})
